import jsonschema

# 定义待校验数据
resp = {"name": "张三",
        "age": 23,
        "hobby": ["吃饭", "再吃饭", "还是吃饭"],
        "sex": None,
        "is_delete": True,
        "height": 1.72
        }
# 定义规则 -- 预期结果
schema = {
    "type": "object",
    "properties": {
        "name": {"type": "string"},
        "age": {"type": "integer"},
        "hobby": {"type":"array"},
        "properties":  {"吃饭":{"type": "string"},"再吃饭":{"type": "string"},
                        "还是吃饭":{"type": "string"} },
        "sex": {"type": "null"},
        "is_delete": {"type": "boolean"},
        "height": {"type": "number"}

    }
}

# 效验规则，校验实际结果与预期规则是否相符
res = jsonschema.validate(instance=resp, schema=schema)
print(res)
